﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace PlaceOrder_Client.Rules
{
    public class NumericValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value == null || string.IsNullOrWhiteSpace(value.ToString()))
            {
                return new ValidationResult(false, "请输入正确数字");
            }

            if (!int.TryParse(value.ToString(), out _))
            {
                return new ValidationResult(false, "请输入正确数字");
            }

            return ValidationResult.ValidResult;
        }
    }

}
